Hi @Nick37129562ryen , You don’t need .name—this assumes a Swatch named "This Color" exists"
var d = app.activeDocument
var allPars = d.allParagraphStyles;
for (var g = 1; g < allPars.length; g++) {
allPars[g].paragraphShadingColor = "This Color";
}
If you are not sure "This Color" exists then:
var d = app.activeDocument
var allPars = d.allParagraphStyles;
var sc = makeSwatch(d, "This Color")
//set the color’s properties
sc.properties = {space:ColorSpace.CMYK, colorValue:[0,50,0,0]}
for (var g = 1; g < allPars.length; g++) {
allPars[g].paragraphShadingColor = "This Color";
}
/**
* Makes a new named Swatch
* @ param the document to add the color to
* @ param color name
* @ return the new swatch
*/
function makeSwatch(d, n){
if (d.colors.itemByName(n).isValid) {
return d.colors.itemByName(n);
} else {
return d.colors.add({name:n});
}
}
... View more